// Tags:
#include <cctype>
#include <cstdio>
#include <cstring>

typedef long long ll;

namespace utl {

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

inline ll max(ll a, ll b) { return a > b ? a : b; }

}  // namespace utl
using utl::read;

const int N = 3e3 + 5;
int n;
int e_cnt, heads[N], siz[N][N], p[N][N];
ll f[N][N];

struct Edge {
  int v, nxt;
} e[N << 1];

inline void add(int u, int v) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt;
}

void pre(int u, int fa, int *siz, int *p) {
  siz[u] = 1, p[u] = fa;
  for (int i = heads[u], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != fa) {
      pre(v, u, siz, p);
      siz[u] += siz[v];
    }
  }
}

ll solve(int x, int y) {
  if (~f[x][y]) return f[x][y];
  if (p[x][y] == x || p[y][x] == y) return (ll)siz[x][y] * siz[y][x];
  f[x][y] = utl::max(solve(x, p[x][y]), solve(p[y][x], y)) +
            (ll)siz[x][y] * siz[y][x];
  return f[x][y];
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen64("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen64("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("mex.in", "r", stdin);
  freopen("mex.out", "w", stdout);
#endif
#endif

  read(n);
  for (int i = 1, u, v; i < n; ++i) {
    read(u), read(v);
    add(u, v), add(v, u);
  }
  memset(f, -1, sizeof(f));
  for (int i = 1; i <= n; ++i) { pre(i, i, siz[i], p[i]); }
  ll ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j) ans = utl::max(ans, solve(i, j));
  printf("%lld", ans);
  return 0;
}